<?php
/**
 * <https://y.st./>
 * Copyright © 2018 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'Coordinates',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2018/05/05.jpg" alt="The street along the route to work" class="framed-centred-image" width="649" height="480"/>
<section id="dreams">
	<h2>Dream journal</h2>
	<p>
		I dreamed I lived in a post-apocalyptic world full of dark magic.
		I lived in a strange, underground bunker with Cyrus, Vanessa, and our mother.
		The bunker was strange in that the inside appeared to be a sunlit field as if it were outside, even at night.
		Nearly everyone was dead.
		The four of us had gone out to forage, and we came across a horrid shrine, for lack of a better word.
		Twelve evil gods used this place do drain the life from what few people remained.
		An elderly stranger came by and explained each of the twelve evils to us.
		I don&apos;t recall them all, but there was a scarecrow and something known as a &quot;twin&quot;.
		The twin used its power to make people love it.
		The scarecrow would make others love you, but you have to give it a human sacrifice for it to do so.
	</p>
	<p>
		We started to leave as it was getting dark, but a part of the shrine started spinning for a couple seconds.
		My mother was stupid enough to start touching another part, which she slightly injured her hand on.
		After she bled on it, the spinning thing spun again for a few seconds, feeding on and drawing power from her blood.
		I tried to hurry us home to the safety of the bunker, but I seemed to be the only one worried.
		I saw a dark, witchlike figure that seemed to be able to teleport, which worried me further.
		We made it into the bunker and hurriedly closed the door, though I feared the witch would find a way to teleport into the bunker, but that didn&apos;t happen.
		Somehow, the bunker was set up so that evil, magical creatures couldn&apos;t enter.
	</p>
</section>
<section id="Minetest">
	<h2>Minetest log</h2>
	<p>
		For years now, I&apos;ve wanted a way to mathematically derive coordinated from a player&apos;s chosen name.
		The problem has been in converting the name into a number; once I have a number, some modulo division can easily be used to put the number into the range I need, then the number can be broken into the three coordinates.
		The obvious answer is to hash the name, but Lua and Minetest have no hashing function.
		Another option has always been to treat the name as a base-something number, but that never works out for me.
		Names can be of different length.
		Two names shouldn&apos;t be represented by the same number before modulo division and no number should be skipped over if I&apos;m going that route, so what do I do?
		There needs to be a character to represent zero, but at the same time, a missing character would also represent zero, like with standard number systems.
		It has to be this way too, as the unused spaces necessarily must be consecutive.
		I can&apos;t make them a full-fledged digit.
	</p>
	<p>
		I finally figured it out though.
		I&apos;ve now got a base 64 system set up, in which the unused character slots act as a &quot;sixty-fifth digit&quot;.
		It&apos;d be like if in base ten, there was in some cases a single character to represent ten.
		Because of where the unused slots are allowed to be, this basically sections off the numeric space so each name length occupies the space directly after the space occupied by names one character longer.
		To a lesser extent, another problem of mine has been that Lua can&apos;t handle numbers as large as I&apos;d need it to work with for computing the unique $a[ID]s associated with each name, but since I&apos;d never gotten far enough for it to matter, I hadn&apos;t put much thought into solving that issue.
		It&apos;s not actually that difficult though.
		I&apos;m going to use modulo division on the end result anyway, so why not use modulo division several times along the way to keep the number small?
		Done in the right places, I get the exact same end result as if I&apos;d waited until the end and only used modulo division once.
	</p>
	<p>
		Disappointingly, the new algorithm puts my own personal map block way up in the sky, near the upper limit of the map.
		I&apos;d prefer one underground, but not too close to the bottom.
		I probably won&apos;t make an actual mod though out of this anyway.
		It&apos;s just too limiting.
		If I provide some sort of incentive for using your mathematically-derived map block, it discourages people from just building where they want to.
		But if I don&apos;t, what is even the point of the mod?
		It&apos;s useless.
		However, it&apos;s nice for my own personal use.
		I like having a mathematically-derived home base coordinate set for myself just because I&apos;m a nerd.
		I&apos;ll probably extend my initial tunnel arm in the direction leading closest to my block, then tunnel toward the right (x, z) value.
		From there, I can tunnel upward to the surface, then pour any excess sandstone I have into towering up to the right y value.
		It&apos;ll be incredibly slow, but it gives me something to do with the sand so I don&apos;t have to store it.
		I&apos;m already going to have chests upon chests or useless flint.
	</p>
</section>
<section id="drudgery">
	<h2>Drudgery</h2>
	<p>
		My discussion post for the day:
	</p>
	<blockquote>
		<p>
			Malnutrition is certainly a huge problem.
			Though my own malnutrition was caused by the attitudes of noxious company I used to keep and not inaccessibility of proper foods, I can say that it certainly wasn&apos;t fun.
			I never felt well and was frequently sick.
			I can easily see how it would&apos;ve gotten worse over time, as is the case with people who have little to no access to proper foods.
		</p>
		<p>
			Malaria&apos;s also a large concern in some parts of the world.
			My sister was working on treatments for it, though she ended up having to stop at least for the time being.
		</p>
	</blockquote>
</section>
END
);
